var page = require('webpage').create(),
    system = require('system'),
    address = system.args[1];

page.open(address, function(status) {
    if (status !== 'success') {
        console.log('next wrongurl');
        phantom.exit();
    } else {
        var nextpageurl = getnext(page);
        if (nextpageurl){
            console.log('next ' + nextpageurl);
        } else {
            console.log('next wrongurl');
        }
        phantom.exit();
    }
});
function getnext(page){
    var nextpageurl = page.evaluate(function(){
        var ret = document.querySelectorAll('div>a.current')[0].nextSibling;
        return ret.href;
    });
    return nextpageurl;
}

setTimeout(function(){
    console.log('next wrongurl');
    phantom.exit();
}, 100000);
